package com.example.util;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;

/**
 * @Author shen
 * @Date 2019/2/18 16:28
 * @Description 分页查询
 **/
@Service
public class RowBoundUtil {

    /**
     * 根据分页属性 生成 RowBounds
     * @param pageSize
     * @param pageIndex
     * @return
     */
    public RowBounds getRowBounds(String pageSize, String pageIndex){
        int limit = Integer.parseInt(pageSize);
        int offset = Integer.parseInt(pageIndex) * limit;
        RowBounds rowBounds = new RowBounds(offset, limit);
        return rowBounds;
    }
}
